<script setup lang="ts">
import { computed } from 'vue';

import { capitalizeFirstLetter, kebabToCamelCase } from '@vben/utils';

import * as icons from '@ant-design/icons-vue';

const props = defineProps({
  icon: {
    type: String,
    default: '',
  },
});
const iconComp = computed(() => {
  if (props.icon.startsWith('ant-design:')) {
    const icon = capitalizeFirstLetter(
      kebabToCamelCase(props.icon.replace('ant-design:', '')),
    );
    return (icons as any)[icon];
  }
  return '';
});
</script>

<template>
  <component :is="iconComp" v-if="iconComp" />
</template>
